package com.kefu.robot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kefu.common.annotation.Permission;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.common.vo.DeleteVo;
import com.kefu.common.vo.DetailVo;
import com.kefu.robot.model.RobotConnectRel;
import com.kefu.robot.service.RobotConnectRelService;
import com.kefu.robot.vo.RobotConnectRelInsertVo;
import com.kefu.robot.vo.RobotConnectRelSearchVo;
import com.kefu.robot.vo.RobotConnectRelUpdateVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author CodeGenerator
 * @date 2021/11/23
 */
@Api(tags = "转人工关键词")
@RestController
@RequestMapping("robot/connectRel")
public class RobotConnectRelController extends AbstractBaseController {

    @Autowired
    private RobotConnectRelService robotConnectRelService;

    @PostMapping("/add")
    @ApiOperation(value = "新增转人工关键词", notes = "新增转人工关键词")
    public Result<String> add(@Validated @RequestBody RobotConnectRelInsertVo robotConnectRelVo) {
    	logger.info("新增转人工关键词:{}", robotConnectRelVo);
    	
    	RobotConnectRel info = robotConnectRelVo.convert();
        robotConnectRelService.save(info);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除转人工关键词", notes = "删除转人工关键词")
    public Result<String> delete(@Validated @RequestBody DeleteVo delete) {
    	logger.info("删除转人工关键词:{}", delete);
    	
        robotConnectRelService.deleteById(delete.getId());
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改转人工关键词", notes = "修改转人工关键词")
    public Result<String> update(@Validated @RequestBody RobotConnectRelUpdateVo robotConnectRelVo) {
    	logger.info("修改转人工关键词:{}", robotConnectRelVo);
    	
    	RobotConnectRel info = robotConnectRelVo.convert();
        robotConnectRelService.update(info);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/detail")
    @ApiOperation(value = "转人工关键词详情", notes = "转人工关键词详情")
    public Result<RobotConnectRel> detail(@Validated @RequestBody DetailVo detail) {

        RobotConnectRel robotConnectRel = robotConnectRelService.findById(detail.getId());
        return ResultGenerator.genSuccessResult(robotConnectRel);
    }

    @PostMapping("/list")
    @ApiOperation(value = "查询转人工关键词", notes = "查询转人工关键词")
    public Result<Page<RobotConnectRel>> list(@Validated @RequestBody RobotConnectRelSearchVo search) {    

        Page<RobotConnectRel> page = robotConnectRelService.search(search);
        return ResultGenerator.genSuccessResult(page);
    }
}
